import java.util.Scanner;

public class T {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = 0;
        for (int i = 0; i <= a; i++) {
            int num = i;
            while (num > 0) {
                int d = num % 10;
                if (d == b) {
                    c++;
                }
                num = num / 10;
            }
        }
        System.out.println(c);
    }
}